package com.ejlchina.keno


fun Int.isEven() = this % 2 != 0
/**
 * 筛选出3连号、4连号、5连号的组合
 */
fun filterContinuous(sourceList: List<Int>): Boolean {
    for (index in 0..2) {
        if (sourceList[index] + 1 == sourceList[index + 1] && sourceList[index + 1] + 1 == sourceList[index + 2]) {
            return true
        }
    }
    return false
}


/**
 * 筛选出有任意2个连续元素的组合
 */
fun filterConsecutiveElements(sortedList: List<Int>): Boolean {
    // 利用已排序特性，只需检查相邻元素的递增差是否为1
    return sortedList.zipWithNext().any { (a, b) -> b - a == 1 }
}

/**
 * 两个list取交集后，交集的元素个数
 */
fun intersectCount(minuend: List<Int>, minus: List<Int>): Int {
    return minuend.intersect(minus.toSet()).size
}

private fun filterLargeGap(sortedList: List<Int>, value: Int) = sortedList.zipWithNext().any { (a, b) -> b - a >= value }

private fun filter4Even1OddOrOpposite(sourceList: List<Int>): Boolean {
    val evenCount = sourceList.count { it % 2 == 0 }
    val oddCount = sourceList.size - evenCount
    return (evenCount == 4 && oddCount == 1) || (evenCount == 1 && oddCount == 4)
}


data class EvenOddBean(
    val firstIsEven: Boolean?,
    val secondIsEven: Boolean?,
    val thirdIsEven: Boolean?,
    val forthIsEven: Boolean?,
    val fifthIsEven: Boolean?
)

data class PageHitCountBean(val pageIndex: Int, val hitCount: Int)
data class PageLineHitCountBean(val pageIndex: Int, val lineColIndex: Int, val hitCount: Int)

data class MustContainOrNotBean(val pageIndex: Int,val lineColIndex: Int, val isContainAny: Boolean)

data class MustContainOrNotEleBean(val mustOrNotList: List<Int>, val isMustContain: Boolean)


data class RangeBean(
    val rang1Count: Int?,
    val range10Count: Int?,
    val range20Count: Int?,
    val range30Count: Int?
)

val RANGE_1_9 = 1 .. 9
val RANGE_10_19 = 10 .. 19
val RANGE_20_29 = 20 .. 29
val RANGE_30_35 = 30 .. 35
const val RANGE_HIT_INCLUDE = -1  //只要在这个区间包含数字就行，不要求具体数量
const val FILTER_ODD = false
const val FILTER_EVEN = true